<template>
  <div>
	 <song-list :songsList="songsList"></song-list>
  </div>
</template>

<script>

import {_Search} from "network/search.js"
import {_getSongsDetail,songDetail} from "network/detail.js"
import SongList from '@/components/common/song-list/song-list'
import {sreach} from '@/mixin/components/sreach'
export default {
  name:'SearchSongs',
  components:{SongList},
  mixins:[sreach],
  data(){
    return{
      songsList:[],
      keywords:'',
	  searchType: 1,
	  songCount:0,
    }
  },
  methods:{
   getList(){
	   if (this.keywords == "") return;
	   this.songsList = [];
	  _Search(this.keywords, this.searchType).then(res=>{
	  		// this.songsList =res.data.result.songs
			let list = res.data.result.songs;
			for (let i in list) {
			  _getSongsDetail(list[i].id).then((res) => {
			    let song = new songDetail(res.data.songs);
			    this.songsList.push(song);
			    // if (i == list.length - 1) {
			      this.songCount = this.songsList.length;
			      /**设置search-detail 搜索信息 */
			      this.$emit("setData", this.songCount, "单曲");
			      // this.$nextTick(() => {
			      //   this.$emit("refresh");
			      // });
			    // }
			  });
			}
			
	  })
   },
  },
  // watch: {
  //   $route: 
  // 	{
  //     handler() {
  //       if (this.$route.path.indexOf("/search-detail") >= 0) {
		// 	console.log(this.$route.params.keywords)
  //         this.keywords = this.$route.params.keywords;
		//   this.getList();
  //       }
  //     },
  //     immediate: true,
  //   },
  // },
}
</script>

<style lang="less" scoped>

</style>
